﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using ENail.Domain.Core;
using ENail.Domain.Core.Contract.Services;
using Equation.Enterprise.Framework.Domain.Data;
using Equation.Enterprise.Utilities.DesignByContract;

namespace ENail.ApplicationServices
{
    public class AssignmentService : IAssignmentService
    {
        private readonly IRepository<Assignment> _assignmentRepository;

        public AssignmentService(IRepository<Assignment> assignmentRepository)
        {
            Check.Require(assignmentRepository != null);

            this._assignmentRepository = assignmentRepository;
        }
        /// <summary>
        /// delete an assignment
        /// </summary>
        /// <param name="id">assgnment id</param>
        /// <returns>number record affected</returns>
    
        public int  DelAssignment(int id)
        {
            Check.Require(id > 0);
            
            Assignment assignment = _assignmentRepository.Get(id);
            _assignmentRepository.Delete(assignment);
            return _assignmentRepository.SaveChanges();
        }
    }
}
